using GameFramework.Network;
using Unity.VisualScripting;
using NetworkCustomErrorEventArgs = UnityGameFramework.Runtime.NetworkCustomErrorEventArgs;

namespace LS.UGFUnits
{
    [UnitShortTitle("Network")]
    [UnitSurtitle("CustomError")]
    public sealed class NetworkCustomError : FrameworkEventUnit<NetworkCustomErrorEventArgs>
    {
        protected override int EventId => NetworkCustomErrorEventArgs.EventId;
        protected override string HookName => UGFHookNames.NetworkCustomError;

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput NetworkChannel
        {
            get;
            private set;
        }

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput CustomErrorData
        {
            get;
            private set;
        }
        
        protected override void Definition()
        {
            base.Definition();
            NetworkChannel = ValueOutput<INetworkChannel>(nameof(NetworkChannel));
            CustomErrorData = ValueOutput<object>(nameof(CustomErrorData));
        }

        protected override void AssignArguments(Flow flow, NetworkCustomErrorEventArgs args)
        {
            base.AssignArguments(flow, args);
            flow.SetValue(NetworkChannel, args.NetworkChannel);
            flow.SetValue(CustomErrorData, args.CustomErrorData);
        }
    }
}